package com.android.JiYclock;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

	private static final String DATABASE_NAME = "alarms.db";
    private static final int DATABASE_VERSION = 2;

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE alarms (" 
        	+  "_id INTEGER PRIMARY KEY," 
        	+  "hour INTEGER, " 
        	+ "minutes INTEGER, " 
        	+ "daysofweek INTEGER, " 
        	+"alarmtime INTEGER, " 
            +  "enabled INTEGER, "
            + "vibrate INTEGER, "
            +"message TEXT, " 
            +"alert TEXT, " 
            + "times INTEGER, "
            + "interval INTEGER," 
            + "location TEXT"
            +    ");");
        
        db.execSQL("CREATE TABLE specialalarms (" 
            	+  "_id INTEGER PRIMARY KEY," 
            	+"year INTEGER,"
            	+"month INTEGER,"
            	+"day INTEGER,"
            	+ "hour INTEGER, " 
            	+ "minutes INTEGER, " 
            	+"alarmtime INTEGER, " 
                +  "enabled INTEGER, "
                + "vibrate INTEGER, "
                +"message TEXT, " 
                +"alert TEXT, " 
                + "times INTEGER, "
                + "interval INTEGER," 
                + "location TEXT"
                +    ");");
        
        

       //  insert default alarms
//        String insertMe = "INSERT INTO alarms " +
//                "(hour, minutes, daysofweek, alarmtime, enabled, vibrate, message, alert,times,interval,location) " +
//                "VALUES ";
//        db.execSQL(insertMe + "(8, 30, 31, 0, 0, 1, '', '',10,0,22);");
//        db.execSQL(insertMe + "(9, 00, 96, 0, 0, 1, '', '',10,0,22);");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
        if (Log.LOGV) Log.v(
                "Upgrading alarms database from version " +
                oldVersion + " to " + currentVersion +
                ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS alarms");
        db.execSQL("DROP TABLE IF EXISTS specialalarms");
        onCreate(db);
    }
}


